using System.Data;
using Crosland.Offline.Core;
using Crosland.Framework.Base;

namespace Crosland.Offline.Data.Helper
{

    public class MaterialHelper : DaoHelperBase
    {
        public MaterialHelper() : base(Entidad, ConstansBase.Aplicacion) 
        {
        }

        public Material Create(IDataReader dr)
        {
            Material entity = new Material();

            int iMatnr = dr.GetOrdinal(this.Matnr);
            if (!dr.IsDBNull(iMatnr)) entity.Matnr = dr.GetString(iMatnr);

            int iVkorg = dr.GetOrdinal(this.Vkorg);
            if (!dr.IsDBNull(iVkorg)) entity.Vkorg = dr.GetString(iVkorg);

            int iVtweg = dr.GetOrdinal(this.Vtweg);
            if (!dr.IsDBNull(iVtweg)) entity.Vtweg = dr.GetString(iVtweg);

            int iMaktx = dr.GetOrdinal(this.Maktx);
            if (!dr.IsDBNull(iMaktx)) entity.Maktx = dr.GetString(iMaktx);

            int iLvorm = dr.GetOrdinal(this.Lvorm);
            if (!dr.IsDBNull(iLvorm)) entity.Lvorm = dr.GetString(iLvorm);

            int iMtart = dr.GetOrdinal(this.Mtart);
            if (!dr.IsDBNull(iMtart)) entity.Mtart = dr.GetString(iMtart);

            int iMatkl = dr.GetOrdinal(this.Matkl);
            if (!dr.IsDBNull(iMatkl)) entity.Matkl = dr.GetString(iMatkl);

            int iBismt = dr.GetOrdinal(this.Bismt);
            if (!dr.IsDBNull(iBismt)) entity.Bismt = dr.GetString(iBismt);

            int iMeins = dr.GetOrdinal(this.Meins);
            if (!dr.IsDBNull(iMeins)) entity.Meins = dr.GetString(iMeins);

            int iSpart = dr.GetOrdinal(this.Spart);
            if (!dr.IsDBNull(iSpart)) entity.Spart = dr.GetString(iSpart);

            int iMtposMara = dr.GetOrdinal(this.MtposMara);
            if (!dr.IsDBNull(iMtposMara)) entity.MtposMara = dr.GetString(iMtposMara);

            int iWerks = dr.GetOrdinal(this.Werks);
            if (!dr.IsDBNull(iWerks)) entity.Werks = dr.GetString(iWerks);

            int iLgort = dr.GetOrdinal(this.Lgort);
            if (!dr.IsDBNull(iLgort)) entity.Lgort = dr.GetString(iLgort);

            int iLabst = dr.GetOrdinal(this.Labst);
            if (!dr.IsDBNull(iLabst)) entity.Labst = dr.GetString(iLabst);

            int iVrkme = dr.GetOrdinal(this.Vrkme);
            if (!dr.IsDBNull(iVrkme)) entity.Vrkme = dr.GetString(iVrkme);

            int iMtpos = dr.GetOrdinal(this.Mtpos);
            if (!dr.IsDBNull(iMtpos)) entity.Mtpos = dr.GetString(iMtpos);

            int iDwerk = dr.GetOrdinal(this.Dwerk);
            if (!dr.IsDBNull(iDwerk)) entity.Dwerk = dr.GetString(iDwerk);

            int iProdh = dr.GetOrdinal(this.Prodh);
            if (!dr.IsDBNull(iProdh)) entity.Prodh = dr.GetString(iProdh);

            int iMarca = dr.GetOrdinal(this.Marca);
            if (!dr.IsDBNull(iMarca)) entity.Marca = dr.GetString(iMarca);

            int iModelo = dr.GetOrdinal(this.Modelo);
            if (!dr.IsDBNull(iModelo)) entity.Modelo = dr.GetString(iModelo);

            return entity;
        }


        #region Mapeo de Campos

        public const string Entidad = "Material";
        public string Matnr = "MATNR";
        public string Maktx = "MAKTX";
        public string Lvorm = "LVORM";
        public string Mtart = "MTART";
        public string Matkl = "MATKL";
        public string Bismt = "BISMT";
        public string Meins = "MEINS";
        public string Spart = "SPART";
        public string MtposMara = "MTPOS_MARA";
        public string Werks = "WERKS";
        public string Lgort = "LGORT";
        public string Labst = "LABST";
        public string Vkorg = "VKORG";
        public string Vtweg = "VTWEG";
        public string Vrkme = "VRKME";
        public string Mtpos = "MTPOS";
        public string Dwerk = "DWERK";
        public string Prodh = "PRODH";
        public string Marca = "marca";
        public string Modelo = "modelo";

        #endregion
    }
}
